<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--
@html_name: 11实例化promise对象
@description: The past cannot be redeemed, the future can be changed.
@author: Jason Black
@create: 2023/6/26 08:17:49
-->
<script>
  const p = new Promise(function (resolve,reject){
    // resolve 表示调用成功    reject 表示调用失败
    setTimeout(()=>{
      let content = "Black"
      if (content === "Jason"){
        resolve(content)
      } else {
        reject(content)
      }
    })
  })
  // 调用成功会执行第一个函数，调用失败会执行第二个函数
  p.then(value => {
    console.log(value)
  },reason => {
    console.log(reason)
  })
</script>
</body>
</html>